package com.ousi.wx.controller;

import com.ousi.wx.common.CommonResult;
import com.ousi.wx.service.MediaService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/process")
@Tag(name = "ProcessController", description = "查询步骤信息管里接口")
@Slf4j
public class ProcessController {
    @Autowired
    private MediaService mediaService;

    @PostMapping("/selectProcessByProductId")
    @Operation(summary = "根据ID查询产品对应的步骤信息")
    public CommonResult selectProcessByProductId(@RequestParam("productId") Integer productId) {
        try {
            List<Map<Integer, Map<String, Object>>> mapList = mediaService.selectProcessByProductId(productId);
            return CommonResult.ok().put(CommonResult.RETURN_RESULT, mapList);
        } catch (Exception e) {
            log.error("查询过程中出现异常", e);
            return CommonResult.error("查询过程中出现异常");
        }

    }
}
